package com.atguigu.jvm;

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;

/**
 * @author atguigu-mqx
 */
public class Student {

    static Student student = null;


    public Student(){
        System.out.println("我是构造.....");
    }
    //  finalize()
    @Override
    protected void finalize() throws Throwable {
        System.out.println("finalize......");
        student = new Student();
        super.finalize();
    }

    public static void main(String[] args) {
        //  创建对象
        student = new Student();
        student = null;
        System.gc(); // 系统的垃圾回收方法(); 开始回收了，一定就会执行finalize();  调用gc() 之后就会立刻执行回收方法么?
        System.out.println("结束.....");
    }
    //  1. 我是构造.....    2.finalize......   3. 结束.....
    //  1. 我是构造.....    2. 结束.....        3.finalize......
}

